<?php

require_once 'common/conn.php';
$result = array();
$usercode = $_GET['usercode'];
if (!isset($usercode)) {
    $usercode = $_POST['usercode'];
}
$playTimes = $_GET['playTimes'];
if (!isset($playTimes)) {
    $playTimes = $_POST['playTimes'];
}

$db = new DBC();
$result['errorNo'] = 0;
if (isset($playTimes)) {
    $data = json_decode($playTimes, true);
    foreach ($data as $value) {
        $sql = "INSERT INTO t_device_product(usercode,flashcode,usedNumberTimes,useTime,type,creatTime) VALUES('" . $usercode . "'," . $value['flashcode'] . "," . $value['times'] . ",'" . $value['playTime'] . "',".$value['type'].",now())";
        if ($db->execute($sql)) {
            $result['errorNo'] = 1;
        }
    }
}
echo json_encode($result);
?>
